package com.community.controller;


import com.community.entity.Result;
import com.community.service.repair.RepairService;
import com.community.service.room.RoomService;
import com.community.service.visitor.VisitorService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;


@Slf4j
@Controller
public class CommonController {

    @Autowired
    private RoomService roomService;


    @Autowired
    private RepairService repairService;

    @Autowired
    private VisitorService visitorService;

    @ResponseBody
    @GetMapping("/updateStatus")
    public Result modifyStatus(@RequestParam("type") String type, @RequestParam("id") String id, @RequestParam("status") String status){

        log.info("type:{}", type);
        if(type.equals("room")){
            log.info("修改后的状态为:{}", status);
            roomService.modifyStatus(id, status);
        }else if(type.equals("repair")){
            repairService.modifyStatus(id, status);
        }else if(type.equals("visitor")){
            visitorService.modifyStatus(id, status);
        }
        return Result.success("");
    }
}
